package lance.honeydew.action;

import java.util.List;

import lance.honeydew.bean.PublishMessage;
import lance.honeydew.bean.SuggestBo;
import lance.honeydew.service.ShopService;
import lance.honeydew.util.GmailUtil;
import lance.honeydew.util.MessageUtil;

import org.apache.log4j.Logger;
import org.apache.struts2.components.ActionMessage;

public class ExplainAction extends BaseAction {

	private static final Logger logger = Logger.getLogger(ExplainAction.class);
	
	/*Bean*/
	private ShopService shopService;
	private SuggestBo suggestBo;
	private List<PublishMessage> publishMessageList;
	
	
	public List<PublishMessage> getPublishMessageList() {
		return publishMessageList;
	}

	public void setPublishMessageList(List<PublishMessage> publishMessageList) {
		this.publishMessageList = publishMessageList;
	}

	public ShopService getShopService() {
		return shopService;
	}

	public void setShopService(ShopService shopService) {
		this.shopService = shopService;
	}

	public SuggestBo getSuggestBo() {
		return suggestBo;
	}

	public void setSuggestBo(SuggestBo suggestBo) {
		this.suggestBo = suggestBo;
	}

	/*Action*/
	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 * explain01.jsp
	 */
	public String execute() {
		
		return SUCCESS;
	}
	
	/**
	 * explain01.jsp
	 * @return
	 */
	public String explain01() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain01";
	}
	
	/**
	 * explain02.jsp
	 * @return
	 */
	public String explain02() {
		
		try {
			
			publishMessageList = shopService.queryPublishMessageByExplain02();
			
			if (publishMessageList == null) {
				addActionMessage("目前暫無公告事項!!");
			}
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain02";
	}
	
	/**
	 * explain03.jsp
	 * @return
	 */
	public String explain03() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain03";
	}
	
	/**
	 * explain04.jsp
	 * @return
	 */
	public String explain04() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain04";
	}
	
	/**
	 * explain05.jsp
	 * @return
	 */
	public String explain05() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain05";
	}
	
	/**
	 * explain06.jsp
	 * @return
	 */
	public String explain06() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain06";
	}
	
	/**
	 * explain07.jsp
	 * @return
	 */
	public String explain07() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain07";
	}
	
	/**
	 * explain08.jsp
	 * @return
	 */
	public String explain08() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain08";
	}
	
	/**
	 * explain09.jsp
	 * @return
	 */
	public String explain09() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain09";
	}
	
	/**
	 * explain10.jsp
	 * @return
	 */
	public String explain10() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain10";
	}
	
	/**
	 * explain11.jsp
	 * @return
	 */
	public String explain11() {
		
		try {
			
			
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain11";
	}
	
	/**
	 * explain12.jsp
	 * @return
	 */
	public String explain12() {
		
		try {
			
			setSuggestBo(new SuggestBo());
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return "explain12";
	}
	
	/**
	 * explain12.jsp
	 * @return
	 */
	public String explain1201() {
		
		try {
			
			if (suggestBo != null) {
				
				String subject = "" +MessageUtil.getString("honeydew.email.subject1");
				String content = "";
				
				content += "會員姓名 : " + suggestBo.getName() + "\n";
				content += "會員帳號 : " + suggestBo.getAccount() + "\n";
				content += "聯絡手機 : " + suggestBo.getPhone() + "\n";
				content += "聯絡信箱 : " + suggestBo.getEmail() + "\n";
				content += "訂單編號 : " + suggestBo.getOrderNumber() + "\n";
				content += "問題類別 : " + suggestBo.getIssueClass() + "\n";
				content += "問題描述 : " + suggestBo.getIssueDesc() + "\n";
				
				String sysEmail = MessageUtil.getString("honeydew.email.system");
				GmailUtil.sendMail(sysEmail, sysEmail, subject, content);
				jsonMessage = "true";
			} else {
				jsonMessage = "false";
			}
			
		} catch(Exception e) {
			jsonMessage = "false";
			logger.debug(e);
		}
		
		return SUCCESS;
	}
}
